<template>
	<view>
		<uni-list>
			<uni-list :border="true">
				<!-- 显示圆形头像 -->
				<uni-list-chat v-for="(pushHistory,index) in pushHistoryList" :key="index" :title="pushHistory.title"
					:to="'/pages/pushTemplate/pushTemplate?id='+pushHistory.id"
					:avatar="urlConfig.oaPrefix + pushHistory.imgUrl" :note="pushHistory.shortContent"
					:time="pushHistory.createTime" :badge-positon="pushHistory.status === 0?'left':''"
					:badge-text="pushHistory.status === 0?'dot':''">
				</uni-list-chat>
			</uni-list>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pushHistoryList: [],
				startSeq: 0,
				limitSize: 30
			}
		},
		methods: {
			selectList() {
				let token = uni.getStorageSync('token');
				uni.$u.http.get(`${this.urlConfig.appServerPrefix}/pushHistory/list`, {
					header: {
						"token": token
					},
					params: {
						startSeq: this.startSeq,
						limitSize: this.limitSize
					}
				}).then(res => {
					// 先实现只展示最新一条吧
					if (!res || !res.data || !res.data.extend || !res.data.extend.list || !res.data.extend
						.list.length) {
						// 没数据
						return;
					}
					this.pushHistoryList = res.data.extend.list;
				}).catch(err => {
					console.log(err)
				});
			},
			onClickItem(pushHistory) {
				uni.navigateTo({
					url: `/pages/pushTemplate/pushTemplate?id=${pushHistory.pushTemplateId}`
				});
			}
		},
		mounted() {
			this.selectList()
		}
	}
</script>

<style>
	.chat-custom-right {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
	}

	.chat-custom-text {
		font-size: 12px;
		color: #999;
	}
</style>
